package com.cc.crm.controller;

import com.cc.crm.pojo.CustomerVisit;
import com.cc.crm.service.CustomerVisitService;
import com.cc.crm.vo.CustomerVisitVo;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * @program:
 * @ClassName:
 * @description:
 * @author: zgc
 * @date:
 * @Version 1.0
 **/
@Controller
@RequestMapping("/visit")
public class CustomerVisitController {
    @Resource
    private CustomerVisitService customerVisitService;
    
    //查询客户拜访信息
    @RequestMapping("/selectCustomerVisit")
    @ResponseBody
    public PageInfo<CustomerVisit> selectCustomerVisit(CustomerVisitVo customerVisitVo) {
        PageInfo<CustomerVisit> pageInfo = customerVisitService.selectVisit(customerVisitVo);
        return pageInfo;
    }
    
    //添加客户拜访信息
    @RequestMapping("/insertCustomerVisit")
    @ResponseBody
    public int insertCustomerVisit(CustomerVisit customerVisit) {
        LocalDateTime dateTime = LocalDateTime.now();
        customerVisit.setDate(dateTime);
        return customerVisitService.insertVisit(customerVisit);
    }
    
    //修改客户拜访信息
    @RequestMapping("/updateCustomerVisit")
    @ResponseBody
    public int updateCustomerVisit(CustomerVisit customerVisit) {
        LocalDateTime dateTime = LocalDateTime.now();
        customerVisit.setDate(dateTime);
        return customerVisitService.updateVisit(customerVisit);
    }
    
    
}
